import http from '@/utils/request'
import type { CategoryQuery, EquipmentCategory, CategoryCreateDTO } from '@/types/device'
import type { Result, PageResult } from '@/types/response'
import type { AxiosResponse } from 'axios'

/** 分页查询设备分类列表 */
export function getCategoryList(params: CategoryQuery): Promise<AxiosResponse<Result<PageResult<EquipmentCategory>>>> {
  return http.get<Result<PageResult<EquipmentCategory>>>('/admin/categories', { params })
}

/** 创建设备分类 */
export function createCategory(data: CategoryCreateDTO): Promise<AxiosResponse<Result<EquipmentCategory>>> {
  return http.post<Result<EquipmentCategory>>('/admin/categories', data)
}

/** 删除设备分类 */
export function deleteCategory(categoryId: number): Promise<AxiosResponse<Result<string>>> {
  return http.delete<Result<string>>(`/admin/categories/${categoryId}`)
}

/** 根据ID查询设备分类 */
export function getCategoryById(categoryId: number): Promise<AxiosResponse<Result<EquipmentCategory>>> {
  return http.get<Result<EquipmentCategory>>(`/admin/categories/${categoryId}`)
} 